package com.hualan.zhsq.controller.car;

import com.hualan.zhsq.entity.car.PayVehicle;
import com.hualan.zhsq.service.car.PayVehicleService;
import com.hualan.zhsq.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName PayVehicleController
 * @Description TODO
 * @Author ZheRan
 * @Date 2025年08月08日 下午2:16
 * @Version 1.0
 */
@RestController
public class PayVehicleController {
    @Qualifier("payVehicleService")
    @Autowired
    private PayVehicleService payVehicleService;

    //插入一条数据
    @PostMapping("/payVehicle/add")
    public Result add(@RequestBody PayVehicle payVehicle) {
        return Result.success(payVehicleService.add(payVehicle));
    }

    //修改一条数据
    @PutMapping("/payVehicle/edit")
    public Result edit(@RequestBody PayVehicle payVehicle) {
        return Result.success(payVehicleService.edit(payVehicle));
    }

    //根据id逻辑删除一条数据
    @DeleteMapping("/payVehicle/remove/{id}")
    public Result remove(@PathVariable Integer id) {
        return Result.success(payVehicleService.remove(id));
    }

    //批量逻辑删除
    @DeleteMapping("/payVehicle/removeBatch")
    public Result removeBatch(@RequestBody Integer[] ids) {
        return Result.success(payVehicleService.removeBatch(ids));
    }

    //根据id查询一条数据
    @GetMapping("/payVehicle/findById/{id}")
    public Result findById(@PathVariable Integer id) {
        return Result.success(payVehicleService.findById(id));
    }

    //查询所有数据
    @GetMapping("/payVehicle/findPage")
    public Result findPage() {
        return Result.success(payVehicleService.findPage(1, 10, new PayVehicle()));
    }

    //查询所有数据包含关联数据
    @GetMapping("/payVehicle/findAllPage")
    public Result findAllPage(Integer pageNum, Integer pageSize, PayVehicle payVehicle) {
        return Result.success(payVehicleService.payVehicle(pageNum, pageSize, payVehicle));
    }

}
